import proFetch from '../../../../hrpub/common/utils/project-fetch';

import {formatDate} from '../../../../hrpub/common/utils/utils'

import { getAppPageConfig } from 'src/hrpub/common/utils/utils';

export default {
    name: 'exam',
    data: {
        config:getAppPageConfig(),
        widget:false,
        refValue:{}, //组织参照
        json:{},//多语
        context:'',
        billStatus:['-1', '3'],//单据状态
        time: 'oneweek', //时间周期
        pageInfo: {
            pageIndex: 1,
            pageSize: 10,
            total: 0,
            totalPage: 1
        }, // 主页面表格的分页信息
        beginTime: "", //开始时间
        endTime: "",//结束时间
        probationType:'3',//3，全部入职1:，试用2
        cardMode:true, //是否卡片模式
        editState:false, //false 浏览态 
        batchAddModalVisible: false, // 批量新增的弹窗显示隐藏
        batchAddCurrentStep: 0, // 批量新增弹窗当前步骤
        billid:null,//当前卡片模式/附件下单挑数据单据id
        billtype:'',
        page:'add', // add新增
        orgStaActiveTab: 'org', // 编制情况的t当前tab
        orgStaOptions: [], // 编制情况里的下拉框内容
        orgStaOrgData: [], // 编制情况的组织编制表格数据
        orgStaDeptData: [], // 编制情况的部门情况表格数据
        orgStaOrgDimension: '', // 编制情况的编制维度
        orgSituationModalVisible:false, //编制情况弹框
        fileManagerModalVisible:false, //附件管理弹框
        approveDetail:false, //查看审批状态
        timeModal:false,
        height:'',
        allpks:[],
        fromApprove:false, //是都是从审批中心跳过来的
        templateFlag: false,
        type:'',//修改时获取的试用类型
        effectTime:formatDate(new Date()),//生效日期
        compositedisplay: false, //指派弹窗 是否显示
        compositedata: null, //指派弹窗数据
        queryCondition:{
            querycondition:{
                logic:"and",
                 conditions:[]
            },
            querytype:'tree'
        },
        nodeRefs: {}    
    },
    sync: {
        update(state, payload) {
            return {
                ...state,
                ...payload
            };
        },
        deepUpdate(state,searchParams) {
            let key = Object.keys(searchParams)
            let value = Object.values(searchParams)
            let params
            let tempState = state
            let tostring = Object.prototype.toString
            key.forEach((v,k)=> {
                let ckey = key[k]
                if(tostring.call(tempState[ckey])==='[object Object]') {
                    params = Object.assign({},state[ckey],{...value[k]})
                    tempState = {
                        ...tempState,
                        [ckey]:params
                    }
                } else {
                    tempState = {
                        ...tempState,
                        [ckey]:searchParams[ckey]
                    }
                }
            })
            return {
                ...state,
                ...tempState
            }
        }
    },
    async: {
         // 获取主页面表格数据
         getMainTableData(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyQueryAction.do',
                body: payload.postData
            });
        },
         // 新增按钮回显数据
         regApplyAddAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyAddAction.do',
                body: payload.postData
            });
        },
         // 新增保存
         regApplySaveAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplySaveAction.do',
                body: payload.postData
            });
        },
          // 批量新增页面根据参照选择获取表格数据
          getBatchAddTableDataByRefer(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBatchAddSelPsnAction.do',
                body: payload.postData
            });
        },
        // 批量新增页面根据查询条件获取表格数据
        getBatchAddTableDataBySearch(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegBatchPsnRefSqlBuilder.do',
                body: payload.postData
            });
        },
        // 表单编辑前
        formEditBefore(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBeforeEditAction.do',
                body: payload.postData
            });
        },
        // 表单编辑后
        formEditAfter(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyAfterEditAction.do',
                body: payload.postData
            });
        },
        // 批量添加页面保存
        batchAddModalSubmit(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBatchSaveAction.do',
                body: payload.postData
            });
        },
        // 复制行数据
        regApplyCopyAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyCopyAction.do',
                body: payload.postData
            });
        },
        // 修改行数据
        regApplyEditAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyEditAction.do',
                body: payload.postData
            });
        },
        // 取消新增
        cancelAdd(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyCancelAction.do',
                body: payload.postData
            });
        },
        // 删除/批量删除
        deleteBatch(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBatchDeleteAction.do',
                body: payload.postData
            });
        },
        // 批量提交
        batchCommit(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyCommitAction.do',
                body: payload.postData
            });
        },
        // 批量收回
        batchBack(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyCallBackAction.do',
                body: payload.postData
            });
        },
        //发送通知
        sendMsgAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplySendMsgAction.do',
                body: payload.postData
            });
        },
        // 执行前校验
        batchImplementBefore(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBeforeExecuteAction.do',
                body: payload.postData
            });
        },
        // 执行
        batchImplement(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyExecuteAction.do',
                body: payload.postData
            });
        },
        // 批量增加下一步渲染form
        batchAddNextStepAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBatchAddNextStepAction.do',
                body: payload.postData
            });
        },
        // 查询单个数据、查看卡片模式
        oneAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyQueryOneAction.do',
                body: payload.postData
            });
        },
        // 编制情况打开弹窗获取初始化数据
        getOrgSituationInitData(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyCheckBudgetAction.do',
                body: payload.postData
            });
        },
        // 批量新增弹框条件选择点击确定
        batchAddSelPsnByConditionAction(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBatchAddSelPsnByConditionAction.do',
                body: payload.postData
            });
        },
        // 批量新增爆保存前校验
        batchAddChack(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBatchSaveCheckAction.do',
                body: payload.postData
            });
        },
        // 批量新增按钮点击前校验
        batchAddChackBefore(dispatch, getState, payload) {
            return proFetch({
                url: '/nccloud/hrtrn/regApply/RegApplyBatchAddAction.do',
                body: payload.postData
            });
        },
        //联查卡片
        linkSearch(dispatch,getState,payload) {
            return proFetch({
                url: '/nccloud/hrhi/psndoc/PsndocCardReptQueryAction.do',
                body: payload.postData
            })
        },
        //小部件跳转接口
        getWidgetTableData(dispatch,getState,payload){
            return proFetch({
                url: '/nccloud/hrtrn/widgets/ListData.do',
                body: payload.postData
            })
        }
    }
}